package com.yznote.cloudesk.config;

import com.alibaba.fastjson.JSON;
import com.yznote.cloudesk.common.pojo.Notice;
import com.yznote.cloudesk.user.server.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class NoticeConfig {
    @Bean
    public NoticeUtil noticeUtil(){
        return new NoticeUtil();
    }
    public static class NoticeUtil{
        @Autowired
        NoticeService noticeService;
        public Boolean sendNotice(Long userId,String title,String content,Object meta,Integer status){
            Notice notice = new Notice();
            notice.setNoticeContent(content);
            notice.setUserId(userId);
            notice.setNoticeTitle(title);
            notice.setNoticeMeta(JSON.toJSONString(meta));
            notice.setNoticeStatus(status);
            return noticeService.noticeUser(notice);
        }
    }
}

